<?php
/**
 * Created by PhpStorm.
 * User: ziniu
 * Date: 2016/6/1
 * Time: 10:20
 */
namespace jingshan;
$t_start = microtime(true);// 开始计算时间
header("Access-Control-Allow-Origin: http://www.miaosha_level2.net"); //防止 跨域
include_once 'lib/Mrgister.class.php';
include_once 'lib/Mredis.class.php';
// 整理数据
$I = new Mrgister();
$I->I();
$value = serialize($I->get_value());
//$data = array(1);
//$callback = $_GET['callback'];
//echo $callback.'('.json_encode($data).')';
//die;
$Mredis = new Mredis();
if($Mredis->set_vaule($value)=='overflow'){
	$url_level1 = 'http://www.miaosha_level1.net/set_file.php';
	$url_level2 = 'http://www.miaosha_level2.net/set_file.php';
	$url_level4 = 'http://www.miaosha_level4.net/set_file.php';
	// 收录完成
	// 触发第一层：
	$ch = curl_init();//初始化 GET 方式
	curl_setopt($ch, CURLOPT_URL, $url_level1);//设置选项，包括URL
	curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
	curl_setopt($ch, CURLOPT_HEADER, 0);
	curl_exec($ch);//执行并获取HTML文档内容
	curl_close($ch);//释放curl句柄
	// 触发第二层：
	$ch = curl_init();//初始化 GET 方式
	curl_setopt($ch, CURLOPT_URL, $url_level2);//设置选项，包括URL
	curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
	curl_setopt($ch, CURLOPT_HEADER, 0);
	curl_exec($ch);//执行并获取HTML文档内容
	curl_close($ch);//释放curl句柄
	// 触发第四层:
	$ch = curl_init();//初始化 GET 方式
	curl_setopt($ch, CURLOPT_URL, $url_level4);//设置选项，包括URL
	curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
	curl_setopt($ch, CURLOPT_HEADER, 0);
	curl_exec($ch);//执行并获取HTML文档内容
	curl_close($ch);//释放curl句柄

	$data = array('msg'=>'false');
}else{
	$data = array('msg'=>'ok');
}
// 消耗时间计算
$t_end = microtime(true);
//echo '耗时'.round($t_end-$t_start,3).'秒';

$callback = $_GET['callback'];
echo $callback.'('.json_encode($data).')';
//die;